package com.household.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * Created By wanzhen
 * 2023. 2023/3/25. 10:47
 */

@Getter
@AllArgsConstructor
public enum SexEnum {
    MALE(1,"male","男"),
    FEMALE(2,"female","女"),
    CONFIDENTIALITY(-1, "confidentiality", "保密");

//    数据库保存值
    @EnumValue
    private Integer type;

    private String name;

    private String cName;

    public static SexEnum getByType(Integer type) {
        return Arrays.stream(values()).filter(e -> e.getType().equals(type)).findFirst().orElse(null);
    }

    public static SexEnum getByName(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
    }
}
